package com.etc.library.exception;

import com.etc.library.util.ResultBody;
import com.mysql.cj.exceptions.ExceptionInterceptor;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    public ResultBody handlerException(Exception e){
        return ResultBody.error(e.getMessage());
    }

    @ExceptionHandler(NullPointerException.class)
    public ResultBody handlerNullPointerException(NullPointerException e){
        return ResultBody.error("空指针异常");
    }
}
